Skip to content

fix(export): capture the latest cell outputs at export time - #12255

Merged
kirangadhave merged 2 commits into
mainfrom
kg/bench-export-snapshots
Dec 3, 2026
Merged

kirangadhave merged 2 commits into
mainfrom
kg/bench-export-snapshots

Conversation

@kirangadhave

@kirangadhave kirangadhave commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

📝 Summary

Read the latest cell outputs when export starts. Previously, each output change rebuilt the full output map and re-rendered the component that owns auto-export, even between exports. If a rich output arrived just before export, the screenshot could also show the previous result. When capture needs a new screenshot, publish the pending display frame before reading the DOM.

Median frontend time across 10 alternating paired runs with 2,000 cells:

Workload Before After
Eight output updates without export 63.91 ms 0.58 ms
Four updates, each followed by export 33.36 ms 3.62 ms
First export after eight updates 0.38 ms 0.92 ms

The eight updates went from eight full-map evaluations and eight React commits in the auto-export component to zero of each. The first export now pays for its snapshot. The benchmark used jsdom with one mounted output and mocked PNG encoding and network requests.

All 72 targeted frontend tests passed. A separate server test verified the latest HTML and image payload in both the manual IPYNB response and the file written by auto-export.

Part of MO-8797.

@kirangadhave
kirangadhave marked this pull request as ready for review December 3, 2026 01:21
@kirangadhave
kirangadhave requested review from mscolnick and peter-gy and a balanced review from Copilot December 3, 2026 01:21
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 606c842.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

If a chart’s lazy import is delayed on its first mount, the PNG capture can contain the loading placeholder instead of the chart. The frame is then marked captured, preventing retries for the unchanged spec even after the chart loads.

1 open issue
What changed in this PR

This PR moves export output collection to export time, reducing background work and publishing pending display state before screenshots.

Changes:

  • Read current outputs without subscribing the auto-export component to updates.
  • Add an explicit display-frame flush before screenshot capture.
  • Test output freshness and absence of unnecessary export renders.
File Description
frontend/​src/​core/​notebook/​replica/​once-per-frame.ts Exposes synchronous flushing.
frontend/​src/​core/​notebook/​replica/​index.ts Exports the shared frame-source type.
frontend/​src/​core/​notebook/​replica/​frame.ts Adds display-frame flushing.
frontend/​src/​core/​export/​hooks.ts Reads current outputs and flushes before capture.
frontend/​src/​core/​export/​__tests__/​output-subscription.test.tsx Checks background reads and renders.
frontend/​src/​core/​export/​__tests__/​output-snapshot.test.tsx Tests fresh manual and automatic export snapshots.
frontend/​src/​core/​executions/​atoms.ts Separates display inputs from current export inputs.
frontend/​src/​core/​executions/​__tests__/​atoms.test.ts Removes the aggregate-output subscription.
frontend/​src/​__mocks__/​executions.ts Adds flushing support to mock frames.

Review effort: Balanced

Comment thread frontend/src/core/export/hooks.ts Resolved
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report for ./frontend

Status Category Percentage Covered / Total
🔵 Lines 69.31% 28722 / 41436
🔵 Statements 69.26% 29278 / 42269
🔵 Functions 64.63% 6906 / 10684
🔵 Branches 64.71% 16831 / 26007
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
frontend/src/__mocks__/executions.ts 94.44% 100% 87.5% 95.71% 235-240, 308-309
frontend/src/components/editor/Output.tsx 70.58% 73.86% 46.66% 70.58% 104, 194-198, 214-234, 256-327, 408, 435, 451-472
frontend/src/components/editor/output/VegaOutput.tsx 100% 75% 100% 100%
frontend/src/core/executions/atoms.ts 100% 98.48% 100% 100%
frontend/src/core/export/hooks.ts 89.87% 72.97% 66.66% 89.87% 49-51, 60-65, 157, 192, 212, 215-217
frontend/src/core/notebook/replica/frame.ts 100% 100% 100% 100%
frontend/src/core/notebook/replica/index.ts 0% 0% 0% 0%
frontend/src/core/notebook/replica/once-per-frame.ts 100% 94.44% 100% 100%
Generated in workflow #26514 for commit 606c842 by the Vitest Coverage Report Action

Comment thread frontend/src/core/export/hooks.ts Resolved
@kirangadhave
kirangadhave enabled auto-merge (squash) December 3, 2026 02:21
@kirangadhave
kirangadhave merged commit a07e463 into main Dec 3, 2026
33 of 34 checks passed
@kirangadhave
kirangadhave deleted the kg/bench-export-snapshots branch December 3, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants